package com.ruoyi.business.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.NotificationsMapper;
import com.ruoyi.business.domain.Notifications;
import com.ruoyi.business.service.INotificationsService;

/**
 * 合同通知Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-02-13
 */
@Service
public class NotificationsServiceImpl implements INotificationsService 
{
    @Autowired
    private NotificationsMapper notificationsMapper;

    /**
     * 查询合同通知
     * 
     * @param id 合同通知主键
     * @return 合同通知
     */
    @Override
    public Notifications selectNotificationsById(Long id)
    {
        return notificationsMapper.selectNotificationsById(id);
    }

    /**
     * 查询合同通知列表
     * 
     * @param notifications 合同通知
     * @return 合同通知
     */
    @Override
    public List<Notifications> selectNotificationsList(Notifications notifications)
    {
        return notificationsMapper.selectNotificationsList(notifications);
    }

    /**
     * 新增合同通知
     * 
     * @param notifications 合同通知
     * @return 结果
     */
    @Override
    public int insertNotifications(Notifications notifications)
    {
        return notificationsMapper.insertNotifications(notifications);
    }

    /**
     * 修改合同通知
     * 
     * @param notifications 合同通知
     * @return 结果
     */
    @Override
    public int updateNotifications(Notifications notifications)
    {
        return notificationsMapper.updateNotifications(notifications);
    }

    /**
     * 批量删除合同通知
     * 
     * @param ids 需要删除的合同通知主键
     * @return 结果
     */
    @Override
    public int deleteNotificationsByIds(Long[] ids)
    {
        return notificationsMapper.deleteNotificationsByIds(ids);
    }

    /**
     * 删除合同通知信息
     * 
     * @param id 合同通知主键
     * @return 结果
     */
    @Override
    public int deleteNotificationsById(Long id)
    {
        return notificationsMapper.deleteNotificationsById(id);
    }

    @Override
    public void sendNotification(Notifications notification) {
        // 这里可集成实际的短信或邮件发送逻辑，此处仅保存通知记录
        notificationsMapper.insertNotification(notification);
    }

    @Override
    public List<Notifications> getUnreadNotifications(Long userId) {
        return notificationsMapper.selectUnreadNotifications(userId);
    }
}
